from calendar import c
import http
from subprocess import getoutput
import requests
import time
import os

os.chdir("/www/wwwroot/xiaohe.luckstare.ltd")

print(time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(time.time())))

commit_local = getoutput("git log")
commit_local = commit_local.split()
commit_local = commit_local[1]
print(commit_local)


url = "https://gitee.com/api/v5/repos/brick-girl/brick-girl/branches/master?"

data = {
    "access_token":"4c104a48dd569a99953026817ebfe4db"
}

r = requests.get(url=url,params=data)
r = r.json()
commit_far = r["commit"]["sha"]
print(commit_far)

if commit_far == commit_local:
    print("无更新！")
else:
    ii = getoutput("git pull origin")
    print(ii)

# 每天1点
guding = "1:00:00"
time1 = time.strftime('%H:%M:%S',time.localtime(time.time()))
if time1 == guding:
    os.chdir("/home/ubuntu")
    getoutput("rm -rf wiki_py.log")

